﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NabaztagCollection.cs" company="Jim Liddell">
//   Copyright © Jim Liddell. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace TeamBuildBunny
{
    #region Usings

    using System;
    using System.Collections;

    #endregion

    /// <summary>
    /// Represents a collection of <see cref="Nabaztag"/> instances.
    /// </summary>
    public class NabaztagCollection : CollectionBase
    {
        #region Indexers

        /// <summary>
        /// The this.
        /// </summary>
        /// <param name="index">
        /// The index.
        /// </param>
        public Nabaztag this[int index]
        {
            get
            {
                return (Nabaztag)this.List[index];
            }

            set
            {
                this.List[index] = value;
            }
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// The add.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// The add.
        /// </returns>
        public int Add(Nabaztag value)
        {
            return this.List.Add(value);
        }

        /// <summary>
        /// The contains.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// The contains.
        /// </returns>
        public bool Contains(Nabaztag value)
        {
            // If value is not of type Int16, this will return false.
            return this.List.Contains(value);
        }

        /// <summary>
        /// The index of.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// The index of.
        /// </returns>
        public int IndexOf(Nabaztag value)
        {
            return this.List.IndexOf(value);
        }

        /// <summary>
        /// The insert.
        /// </summary>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        public void Insert(int index, Nabaztag value)
        {
            this.List.Insert(index, value);
        }

        /// <summary>
        /// The play all.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        public void PlayAll(string text)
        {
            foreach (Nabaztag nabaztag in this.List)
            {
                nabaztag.Play(text);
            }
        }

        /// <summary>
        /// The remove.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        public void Remove(Nabaztag value)
        {
            this.List.Remove(value);
        }

        #endregion

        #region Methods

        /// <summary>
        /// The on validate.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <exception cref="ArgumentException">
        /// </exception>
        protected override void OnValidate(object value)
        {
            if (value.GetType() != typeof(Nabaztag))
                throw new ArgumentException("value must be of type Nabaztag.", "value");
        }

        #endregion
    }
}